<?php
declare (strict_types=1);

namespace app\api\controller;

use app\common\model\Maintain;
use app\common\tool\Result;
use think\facade\View;
use think\response\Json;
use app\common\model\Reservation as ReservationModel;

class Reservation extends Base
{

    /**
     * get: 维修类型
     * path: save
     * method: save
     */
    public function maintain()
    {
        $maintain = Maintain::where(['is_del'=>0,'status'=>1])->field('id,title')->select();
        return Result::success('获取成功',$maintain);
    }



    /**
     * get: 添加留言预约
     * path: save
     * method: save
     * param: name 姓名
     * param: mobile 手机号
     * param: images 图片
     * param: province 省
     * param: city 市
     * param: district 区
     * param: town 街道
     * param: details 详细地址
     * param: content 要求
     * param: desire_time 期望时间
     * param: maintain 维修类型
     */
    public function save()
    {
        $param = $this->request->param();
//        if(!$this->user->nickname)
//        {
//            return Result::fail('请先完善昵称');
//        }
//        if(!$this->user->mobile)
//        {
//            return Result::fail('请先完善手机号');
//        }
//        if(!$this->user->photo)
//        {
//            return Result::fail('请先完善头像');
//        }
//        $num = \app\common\model\Address::where(['uid'=>$this->user->id,'default'=>1])->count();
//        if(!$num)
//        {
//            return Result::fail('请先设置默认地址');
//        }
        $param['create_time'] = time();
        $create = ReservationModel::create($param);
        ReservationModel::PushReservation($param);
        if($create)
        {
            return Result::success('提交成功');
        }else{
            return Result::fail('提交失败');
        }
    }


}

